import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace InfraHolidayAdjustmentApi {
  /** 假期调休信息 */
  export interface HolidayAdjustment {
    id: number; // 主键
    adjustType?: number; // 调整类型：1-补课(补班) 2-补休
    naturalYear: string; // 自然年度
    holidayId: number; // 关联的假期ID
    originalDate?: Dayjs | string; // 原始日期
    adjustDate?: Dayjs | string; // 调整日期
    reason?: string; // 调休原因
    status?: number; // 有效状态
  }
}

/** 查询假期调休分页 */
export function getHolidayAdjustmentPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<InfraHolidayAdjustmentApi.HolidayAdjustment>
  >('/infra/holiday-adjustment/page', data, { desensitize, encrypt });
}

/** 查询假期调休详情 */
export function getHolidayAdjustment(id: number) {
  return requestClient.get<InfraHolidayAdjustmentApi.HolidayAdjustment>(
    `/infra/holiday-adjustment/get?id=${id}`,
  );
}

/** 新增假期调休 */
export function createHolidayAdjustment(
  data: InfraHolidayAdjustmentApi.HolidayAdjustment,
) {
  return requestClient.post('/infra/holiday-adjustment/create', data);
}

/** 修改假期调休 */
export function updateHolidayAdjustment(
  data: InfraHolidayAdjustmentApi.HolidayAdjustment,
) {
  return requestClient.put('/infra/holiday-adjustment/update', data);
}

/** 删除假期调休 */
export function deleteHolidayAdjustment(id: number) {
  return requestClient.delete(`/infra/holiday-adjustment/delete?id=${id}`);
}

/** 批量删除假期调休 */
export function deleteHolidayAdjustmentList(ids: number[]) {
  return requestClient.delete(
    `/infra/holiday-adjustment/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出假期调休 */
export function exportHolidayAdjustment(params: any) {
  return requestClient.download('/infra/holiday-adjustment/export-excel', {
    params,
  });
}
